﻿function ShowClientUpdateLocationMap(LocationMapID, Title) {
    Url = Portal.SODC.IDIS.LocationMap.GetShowUpdateForm(LocationMapID, Title).value;
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    //refresh form
    $("#divMapLocationMain").html(SODC.IDIS.LocationMap.LocationMap.GetHtml().value);
    repairNewTree();
}
function repairNewTree() {
    $("#treelocations").treeview({
        //control: "#treecontrol",
        animated: "fast",
        collapsed: true,
        //unique: true
    });
}

function ClientUpdateLocationMap(LocationMapID) {
    Url = Portal.SODC.IDIS.LocationMapUpdateForm.ServerSideUpdateLocationMap(LocationMapID, $("#txtLocationName").val()).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    alert(Url);
    window.close();
}
function ShowClientAddLocationMap(LocationMapID) {
    Url = Portal.SODC.IDIS.LocationMap.GetShowInsertForm(LocationMapID).value;
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');

    //refresh form
    $("#divMapLocationMain").html(SODC.IDIS.LocationMap.LocationMap.GetHtml().value);
    repairNewTree();
}
function ClientAddLocationMap(ParentID) {
    Url = Portal.SODC.IDIS.LocationMapInsertForm.ServerSideAddCategory(ParentID, $("#txtLocationName").val()).value;
    if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
    }
    alert(Url);
    window.close();
}
function ClientDeleteLocationMap(LocationMapID) {
    if (confirm("Bạn đã chắc chắn xóa dữ liệu này chưa?"))
    {
        Url = Portal.SODC.IDIS.LocationMap.ServerSideDeleteCategory(LocationMapID).value;
        if (Url.indexOf("ERROR") != -1) {
        alert(Url);
        return;
        }
    }
}
function ClientRefreshLocationMap()
{
    ret = Portal.SODC.IDIS.LocationMap.GetHtml().value;
    if (ret.indexOf("ERROR") != -1) {
        alert(ret);
        return;
    }
    $('#divMapLocationMain').html(ret);
    repairNewTree();
}
function ClientLoadSubLocations(LocationMapID, DisplayTag)
{
    $("#link"+LocationMapID).hide();
    ret = Portal.SODC.IDIS.LocationMap.ServerSideGetSubLocation(LocationMapID).value;
    if (ret.indexOf("ERROR") != -1) {
        alert(ret);
        return;
    }
    $("#"+LocationMapID).append(ret);
}